package com.guardchina.framework.mybatis.model;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: ${描述}
 * @author: lwb
 * @date:
 */
@Data
public class CustomPage<T> {

    private Long pageNo;

    private Long pageSize;

    private Long totalSize;

    private Long totalPage;

    private List<T> record;

    public CustomPage(IPage<T> page){
        this.pageNo = page.getCurrent();
        this.pageSize = page.getSize();
        this.totalSize = page.getTotal();
        this.totalPage = page.getPages();
        this.record = page.getRecords();
    }

    public CustomPage(IPage page, List<T> record){
        this.pageNo = page.getCurrent();
        this.pageSize = page.getSize();
        this.totalSize = page.getTotal();
        this.totalPage = page.getPages();
        this.record = record;
    }

    public CustomPage(Long pageNo, Long pageSize){
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.totalPage = 0L;
        this.totalSize = 0L;
        this.record = new ArrayList<>();
    }
}
